#ifndef TOUCH_H
#define TOUCH_H


#include <iostream>

#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

#include <sys/mman.h>


#include <linux/input.h>//触摸屏头文件

class Point{
public:
    Point(int x=0,int y=0);
    ~Point();

    int x();
    void setX(int x);

    int y();
    void setY(int y);

    void setXY(int x,int y);
    Point pointXY();
private:

    int m_x;
    int m_y;
};


class Touch
{

public:

    enum BoardType{
        BOARD_TYPE_GEC6818_BLACK,//黑色板卡型号
        BOARD_TYPE_GEC6818_BLUE,//蓝色板卡型号
    };
    Touch(enum BoardType type = BOARD_TYPE_GEC6818_BLUE, const char*deviceName = "/dev/input/event0");
    ~Touch();

    //获取触摸屏的坐标
    int wait(int&rx,int&ry);
    int wait(Point &val);
    Point wait();

    int x(); //返回x的坐标
    int y(); //返回y的坐标

    Point point(); //返回XY的坐标

    enum BoardType boardType();
    void setBoardType(enum BoardType type);

    static Touch* intstance(enum BoardType type = BOARD_TYPE_GEC6818_BLACK);

private:
    char m_deviceName[256];
    Point m_point; //保存X Y 的坐标
    enum BoardType m_type;

    static Touch* m_instance;


};

#endif // TOUCH_H
